<template>
  <div>
    富文本编辑器
    <QuillEditor 
      v-model:content="cont" 
      content-type="html" 
      @textChange="handleChange"
      theme="snow"
      :toolbar="toolbarOptions"
    />
    <n-button type="primary" size="medium" @click="handleRichText">
      提取并使用富文本内容
    </n-button>
    <div v-html="cont"></div>
    <n-button type="primary" size="medium" @click="copy(words)">
      点击复制文本   {{ copied?'已复制':'' }}
    </n-button>
    <div>{{ words }}</div>
  </div>
</template>

<script setup>
import { QuillEditor } from '@vueup/vue-quill'
import '@vueup/vue-quill/dist/vue-quill.snow.css';
import '@vueup/vue-quill/dist/vue-quill.bubble.css';
import { ref } from 'vue';
const cont = ref('')
const handleChange = ()=>{
  console.log('正在输入');
}
const handleRichText = ()=>{
  console.log(cont);
  
}

const toolbarOptions = [
  ['bold', 'italic', 'underline', 'strike'],        // toggled buttons
  ['blockquote', 'code-block'],
  ['link', 'image', 'video', 'formula'],
  [{ 'header': 1 }, { 'header': 2 }],               // custom button values
  [{ 'list': 'ordered'}, { 'list': 'bullet' }, { 'list': 'check' }],
  [{ 'script': 'sub'}, { 'script': 'super' }],      // superscript/subscript
  [{ 'indent': '-1'}, { 'indent': '+1' }],          // outdent/indent
  [{ 'direction': 'rtl' }],                         // text direction
  [{ 'size': ['small', false, 'large', 'huge'] }],  // custom dropdown
  [{ 'header': [1, 2, 3, 4, 5, 6, false] }],
  [{ 'color': [] }, { 'background': [] }],          // dropdown with defaults from theme
  [{ 'font': [] }],
  [{ 'align': [] }],
  ['clean']                                         // remove formatting button
];

const words = ref('')
for(let i=15000;i<20000;i++){
  words.value += String.fromCharCode(i)
}
import { useClipboard } from '@vueuse/core'

const source = ref('Hello')
const { text, copy, copied, isSupported } = useClipboard({ source })

</script>

<style lang="scss" scoped>

</style>